﻿using System;
using System.ComponentModel;

namespace AutoCommunication.Enums
{
    /// <summary>
    /// 变量是只读/只写/还是能读能写
    /// </summary>
    public enum WriteOrRead
    {
        /// <summary>
        /// 只能写
        /// </summary>
        OnlyWrite,

        /// <summary>
        /// 只能读
        /// </summary>
        OnlyRead,

        /// <summary>
        /// 能读能写
        /// </summary>
        ReadAndWrite
    }

    /// <summary>
    /// 报警等级
    /// </summary>
    public enum AlarmLevel
    {
        /// <summary>
        /// 超级大错误,不处理会爆炸的错误
        /// </summary>
        Fatal,

        /// <summary>
        /// 大错误,需要处理
        /// </summary>
        Error,

        /// <summary>
        /// 小错误,可能不会出错,但是这样做是不对的
        /// </summary>
        Warning,

        /// <summary>
        /// 平常的信息
        /// </summary>
        Info,

        /// <summary>
        /// 调试
        /// </summary>
        Debug,

        /// <summary>
        /// 设备断开连接
        /// </summary>
        DisConnect,

        /// <summary>
        /// 暂时用不到
        /// </summary>
        Off
    }

    /// <summary>
    /// Encoding格式枚举
    /// </summary>
    public enum EncodingEnum
    {
        /// <summary>
        ///
        /// </summary>
        UTF8,

        /// <summary>
        ///
        /// </summary>
        Unicode,

        /// <summary>
        ///
        /// </summary>
        BigEndianUnicode,

        /// <summary>
        ///
        /// </summary>
        ASCII,

        /// <summary>
        ///
        /// </summary>
        Default
    }

    /// <summary>
    /// ModbusStore存储区
    /// </summary>
    public enum ModbusStore
    {
        /// <summary>
        /// 输入线圈
        /// </summary>
        InCoil,

        /// <summary>
        /// 输出线圈
        /// </summary>
        OutCoil,

        /// <summary>
        /// 输入寄存区
        /// </summary>
        InRegister,

        /// <summary>
        /// 保持性存储区
        /// </summary>
        HoldRegister,
    }

    /// <summary>
    /// 西门子型号版本
    /// </summary>
    [Flags]
    public enum SiemensVersion
    {
        /// <summary>
        /// 未定义
        /// </summary>
        [Description("未定义")]
        None = 0,

        /// <summary>
        /// 西门子S7-200 【需要配置网络模块】
        /// </summary>
        [Description("西门子S7-200")]
        S7_200 = 1,

        /// <summary>
        /// 西门子S7-200Smar
        /// </summary>
        [Description("西门子S7-200Smar")]
        S7_200Smart = 2,

        /// <summary>
        /// 西门子S7-300
        /// </summary>
        [Description("西门子S7-300")]
        S7_300 = 3,

        /// <summary>
        /// 西门子S7-400
        /// </summary>
        [Description("西门子S7-400")]
        S7_400 = 4,

        /// <summary>
        /// 西门子S7-1200
        /// </summary>
        [Description("西门子S7-1200")]
        S7_1200 = 5,

        /// <summary>
        /// 西门子S7-1500
        /// </summary>
        [Description("西门子S7-1500")]
        S7_1500 = 6,
    }

    /// <summary>
    /// 西门子存储区,西门子官方手册上有这个代码的介绍
    /// </summary>
    public enum SiemensStore : byte
    {
        /// <summary>
        /// DB区,数据存储区
        /// </summary>
        DB = 0x84,//=132

        /// <summary>
        /// M区,内部继电器
        /// </summary>
        M = 0x83,//=131

        /// <summary>
        /// 输入线圈
        /// </summary>
        I = 0x81,//=129

        /// <summary>
        /// 输出线圈
        /// </summary>
        Q = 0x82,//=130

        /// <summary>
        ///计时器
        /// </summary>
        T = 0x1D,//=29,

        /// <summary>
        /// 计数器
        /// </summary>
        C = 0x1C//=28
    }

    /// <summary>
    /// Modbus功能码
    /// </summary>
    public enum ModbusFunCode : byte
    {
        /// <summary>
        /// 读输出寄存器
        /// </summary>
        ReadOutCoil = 0x01,

        /// <summary>
        /// 读输入寄存器
        /// </summary>
        ReadInCoil = 0x02,

        /// <summary>
        /// 读保持性寄存器
        /// </summary>
        ReadHoldRegister = 0x03,

        /// <summary>
        /// 读输入寄存器
        /// </summary>
        ReadInRegister = 0x04,

        /// <summary>
        /// 写单线圈
        /// </summary>
        WriteSingleCoil = 0x05,

        /// <summary>
        /// 写单个寄存器
        /// </summary>
        WriteSingleRegister = 0x06,

        /// <summary>
        /// 写多线圈
        /// </summary>
        WriteMutilCoil = 0x0F,

        /// <summary>
        /// 写多个寄存器
        /// </summary>
        WriteMutilRegister = 0x10
    }
}